import { Badge, Button, message, Popconfirm, Space, TableColumnsType, Tag, Typography } from 'antd'
import type { ITableData } from './types'
import { downloadByOwnUrl } from '@/utils/util'

export const useIndexColumns = (onEdit: (info: ITableData) => void): TableColumnsType<ITableData> => [
  {
    title: '模板名称',
    dataIndex: 'excelTemplateName',
    key: 'excelTemplateName',
    align: 'center',
    render: (info) => {
      return info ? info : '-'
    },
  },
  {
    title: '模板URL',
    dataIndex: 'fileUrl',
    key: 'fileUrl',
    align: 'center',
    render: (info) => {
      return (
        <Typography.Link
          onClick={() => {
            downloadByOwnUrl(info)
          }}
        >
          文件下载
        </Typography.Link>
      )
    },
  },
  {
    fixed: 'right',
    title: '操作',
    width: 230,
    align: 'center',
    render: (info) => {
      {
        return (
          <Space size="large">
            <Typography.Link
              onClick={() => {
                onEdit(info)
              }}
            >
              编辑
            </Typography.Link>
          </Space>
        )
      }
    },
  },
]
